home *** CD-ROM | disk | FTP | other *** search
/ Maximum CD 1999 June / maximum-cd-1999-06.iso / Fireworks 2 / data1.cab / Dreamweaver_2_Files / Configuration / Behaviors / Actions / Group Over.js < prev    next >
Encoding:
JavaScript  |  1999-03-01  |  20.8 KB  |  580 lines

  1. //*************** GLOBALS VARS *****************
  2. // Supporting Fireworks 2.0 10FEB99
  3.  
  4. //******************* BEHAVIOR FUNCTIONS **********************
  5.  
  6. //Changes multiple images at once. Accepts a variable number of args in triplets as follows:
  7. //  objStrNS - Javascript object ref for Netscape (ex: document.layers['foo'].document.myImage)
  8. //  objStrIE - JScript object reference for Internet Explorer (ex: document.all['myImage'])
  9. //  imgURL   - an image filename, URL encoded. (ex: file.gif, http://www.x.com/y.gif)
  10. //
  11. //Tests for browser, and uses the first object string for NS, the second for IE.
  12. //Sets the image src property to the new filename: document.myImage.src = file.gif.
  13. //Fails gracefully on older browsers by ensuring the the object exists.
  14. //If the image is in a layer, fixes the reference so it works. It doesn't hurt
  15. //to set image.src in a browser (IE3) even if nothing changes.
  16. //The rest of the code is to support another Action, Swap Image Restore.
  17. //Builds an array of the original src values and saves it to a global property,
  18. //in the form of theObj,theObj.src,.... Prevents overwriting these values if called
  19. //repeatedly, to ensure we use the original src file set in the HTML.
  20.  
  21. function GrpSwap(grp){
  22.     var i,j=0,newSrc,objName;
  23.     var docGroup = false;
  24.     for (i=1; i < (GrpSwap.arguments.length-1); i+=2) {
  25.         objName = GrpSwap.arguments[i];
  26.         newSrc = GrpSwap.arguments[i+1];
  27.         docGroup = FindGroup(grp, objName);
  28.         if (!docGroup) continue;
  29.         obj = FWFindImage(document,objName,0);
  30.         if (!obj) continue;
  31.         if (obj.isDown) {
  32.             if (obj.downOver) { 
  33.                 obj.src = obj.downOver;
  34.             }
  35.         } else {
  36.             obj.src = newSrc;
  37.             obj.atRestSrc = obj.initialSrc;
  38.         }
  39.         obj.skipMe = true;
  40.         j++;
  41.     }
  42.     if (!docGroup) return;
  43.     theImages = docGroup.theImages;
  44.     if (theImages) {
  45.         for (i=0; i<theImages.length; i++) {
  46.             var curImg = theImages[i];
  47.             if (curImg.atRestSrc && !curImg.skipMe) {
  48.                 curImg.src = curImg.atRestSrc;
  49.             }
  50.             curImg.skipMe = false;
  51.         }
  52.     }
  53. }
  54.  
  55. function GrpRestore(grp){
  56.     var docGroup = eval("document.FWG_"+grp);if (!docGroup) return;
  57.     theImages = docGroup.theImages;
  58.     if (theImages) {
  59.         for (i=0; i<theImages.length; i++) {
  60.             var curImg = theImages[i];
  61.             if (curImg.atRestSrc) {
  62.                 curImg.src = curImg.atRestSrc;
  63.             }
  64.         }
  65.     }
  66. }
  67.  
  68. function FWFindImage(doc, name, j)
  69. {
  70.     var theImage=false;
  71.     if (doc.images) {
  72.         theImage = doc.images[name];
  73.     }
  74.     if (theImage) return theImage;
  75.     if (doc.layers) {
  76.         for (j=0; j<doc.layers.length; j++) {
  77.             theImage = FWFindImage(doc.layers[j].document, name, 0);
  78.             if (theImage) return(theImage);
  79.         }
  80.     }
  81.     return(false);
  82. }
  83.  
  84. function FindGroup(grp, imageName) {
  85.     var img = FWFindImage(document, imageName, 0);
  86.     if (!img) return(false);
  87.     var docGroup = eval("document.FWG_"+grp);
  88.     if (!docGroup) {
  89.         docGroup = new Object;
  90.         eval("document.FWG_"+grp+" = docGroup");
  91.         docGroup.theImages = new Array;
  92.     }
  93.     if (img) {
  94.         var i;
  95.         for (i=0; i<docGroup.theImages.length; i++) {
  96.             if (docGroup.theImages[i] == img) break;
  97.         }
  98.         docGroup.theImages[i] = img; 
  99.         if (!img.atRestSrc) {
  100.             img.atRestSrc = img.src;
  101.             img.initialSrc = img.src;
  102.         }
  103.     }
  104.     return(docGroup);
  105. }
  106.  
  107. //Preloads multiple images files in order. Accepts a variable number of args
  108. //(each should be quoted):
  109. //  imgURL   - an image filename, URL encoded. (ex: file.gif, http://www.x.com/y.gif)
  110. //
  111. //Creates a new array of Image objects. With each one, it assigns an image source
  112. //from the argument list. These are downloaded essentially simultaneously into the
  113. //client cache. When the user needs a new image file (for example: they go to the
  114. //next web page), the browser should quickly find this image in the cache.
  115. //!!! IMPORTANT !!! This function is also defined in file "Preload Images.htm".
  116. //Any edits must be made there as well as here.
  117.  
  118. function MM_preloadImages() { //v2.0
  119.   if (document.images) {
  120.     var imgFiles = MM_preloadImages.arguments;
  121.     if (document.preloadArray==null) document.preloadArray = new Array();
  122.     var i = document.preloadArray.length;
  123.     with (document) for (var j=0; j<imgFiles.length; j++) if (imgFiles[j].charAt(0)!="#"){
  124.       preloadArray[i] = new Image;
  125.       preloadArray[i++].src = imgFiles[j];
  126.   } }
  127. }
  128.  
  129.  
  130. //******************* API **********************
  131.  
  132.  
  133. //Checks for the existence of images.
  134. //If none exist, returns false so this Action is grayed out.
  135.  
  136. function canAcceptBehavior(){
  137.   var retVal = "";
  138.   var imgs = getAllObjectRefs("IE 4.0","IMG");
  139.   if (imgs.length > 0) {
  140.     retVal = "onMouseOver";
  141.   }
  142.   if (retVal)
  143.     return retVal;
  144.   return false;
  145. }
  146.  
  147.  
  148.  
  149. //Returns Javascript functions to be inserted in HTML head with script tags.
  150.  
  151. function behaviorFunction(){       
  152.   return "MM_preloadImages,FindGroup,FWFindImage,GrpRestore,GrpSwap"
  153. }
  154.  
  155.  
  156. //Returns fn call to insert in HTML tag <TAG... onEvent='thisFn(arg)'>
  157. //Gets list of imgSrcs from doc attribute. With each imgSrc, it gets the parallel
  158. //img name from select 'menu'. Each imgSrc & imgObj are embedded as args.
  159. function applyBehavior() {
  160. /*
  161.     return "GrpSwap('Joe','Foo','foo.img')"
  162. }
  163. function yo() {
  164. */
  165.   var retVal="",i,j,argList="",fnArray,imgSrcArray,imgSrc,imgObj,imgObjIE,newName;
  166.   var imgObjsArray=document.MM_imgObjsArray;
  167.   var imgList="";
  168.  
  169.   grpName = document.theForm.grpName.value;
  170.   imgSrcArray = document.MM_myImgSrcs;      //get global list of imgSrcs
  171.   for (i=0; i<imgSrcArray.length; i++) {    //with each imgSrc
  172.     imgSrc = imgSrcArray[i];
  173.     if (imgSrc) {      //if not empty
  174.       if (argList) argList += ",";    //if stuff already in list, add comma
  175.       theName = imgObjsArray[i].getAttribute("name");
  176.       if (!theName){  //if the image is unnamed
  177.          //from this array, get unique image name
  178.         newName = getUniqueName("IMG","Image",imgObjsArray); 
  179.         imgObjsArray[i].setAttribute("name",newName); //rename image in document
  180.          theName = imgObjsArray[i].getAttribute("name");
  181.       }
  182.      argList += "'"+escape(theName)+"','"+escape(imgSrc)+"'";
  183.       imgList += (imgList?",":"")+"'"+escape(imgSrc)+"'";
  184.        break;
  185.     }
  186.   }
  187.   if (!argList) retVal = MSG_NoImgsSelected;
  188.   else { //OK
  189.     //Add or remove MM_swapImgRestore() based on checkbox setting
  190.     selObj = dreamweaver.getBehaviorElement();
  191.     if (!selObj){
  192.       selArr = dreamweaver.getSelection();
  193.       selObj = dreamweaver.offsetsToNode(selArr[0],selArr[1]);
  194.     
  195.     }
  196.  
  197.     //Add or remove MM_preloadImages() based on checkbox setting
  198.     var obj = dreamweaver.getDocumentDOM("document").body;
  199.     if (document.theForm.preload.checked) { //add preload call to onLoad handler
  200.       argList += ",\'"+document.preloadId+"\'"; //add uniqueName to main fn call
  201.       setHandler(obj,"onLoad","MM_preloadImages("+imgList+",'"+document.preloadId+"')",document.preloadId);
  202.     } else {
  203.       delHandler(obj,"onLoad","MM_preloadImages",document.preloadId);
  204.     }
  205.  
  206.     if (document.theForm.restore) {
  207.       var theRestore = "GrpRestore('" + grpName + "')";
  208.       if (document.theForm.restore.checked) { //add restore to onMouseOut handler
  209.         setHandler(selObj,'onMouseOut',theRestore);
  210.       } else { //remove it
  211.         delHandler(selObj,'onMouseOut', 'GrpRestore', grpName);
  212.       }
  213.     }
  214.  
  215.     retVal = "GrpSwap('"+grpName+"'," + argList+")";  //create correct function call
  216.   }
  217.     return retVal
  218. }
  219.  
  220.  
  221. //Given the original function call, this parses out the args and updates
  222. //the UI. Loops through each imgObj,imgSrc pair.
  223. //If imgObj already present in menu, stuff imgSrc in imgSrcArray. If imgObj
  224. //doesn't exist, add to menu, and extend imgSrcArray.
  225.  
  226. function inspectBehavior(behFnCallStr){
  227.   var argArray,imgSrcArray,found,numImgs,i,imgObj,imgSrc,j,imgObjNum;
  228.   var imgsArray = document.MM_imgObjsArray = createObjsArray("IMG");
  229.  
  230.   argArray = extractArgs(behFnCallStr);//get new list of imgObj,imgSrc pairs
  231.   imgSrcArray = document.MM_myImgSrcs; //get the prior list of imgSrcs
  232.   group=unescQuotes(argArray[1]);
  233.   numImgs = document.MM_imgObjsArray.length;
  234.   for (i=2; i<(argArray.length-1); i+=2){ //with each imgObj,imgSrc pair
  235.     imgName=unescQuotes(argArray[i]);
  236.     imgSrc=unescape(argArray[i+1]);
  237.     found = false;
  238.     for (j=0; j<numImgs; j++){  //check if imgObj is in ref list
  239.         theName = document.MM_imgObjsArray[j].getAttribute("name");
  240.         if (theName == imgName) { //if imgObj there
  241.             imgSrcArray[j] = imgSrc;              //store imgSrc at that pos
  242.             if (imgSrc) addStarToMenuItem(document.theForm.menu,j);//if non-empty, mark with  *
  243.             found = true;
  244.             break;
  245.         }
  246.     }
  247.     if (!found) alert(errMsg(MSG_ImgNotFound,imgName,imgSrc)); //if image name not found
  248.   }
  249.   document.theForm.grpName.value = group;
  250.   document.MM_myImgSrcs = imgSrcArray; //save updated imageSrc list
  251.   displayImgSrc();         //load the imageSrc for selected image
  252.  
  253.   //Determine if preloading, get id
  254.   if (i < argArray.length) document.preloadId = argArray[i]; //unique id exists, get it
  255.    document.theForm.preload.checked = (argArray.length > i); //if preload, check box
  256.  
  257.   //If restore checkbox is available, see if MM_swapImgRestore() exists, and check the box
  258.   var theObj = findObject("restoreOption");
  259.   if (theObj) { //restore checkbox is a possibility
  260.     var selObj=dreamweaver.getBehaviorElement();
  261.     if (selObj && selObj.tagName != "A") selObj = selObj.parentNode; //move out to A tag if needed
  262.     if (selObj && selObj.tagName == "A") if (document.theForm.restore) {
  263.       document.theForm.restore.checked = getHandler(selObj,'onMouseOut','GrpRestore', group);
  264.     }
  265.   }
  266.  
  267. }
  268.  
  269.  
  270. //Given the original function call, this parses out the args and updates
  271. //the code. If there's a preload id at the end of the arglist, deletes
  272. //the preload handler. If there's a swap restore call, deletes that.
  273.  
  274. function deleteBehavior(behFnCallStr){
  275.   var argArray,obj,selArr,selObj;
  276.  
  277.   argArray = extractArgs(behFnCallStr);//get new list of imgObj,imgSrc pairs
  278.   group=unescQuotes(argArray[1]);
  279.  
  280.   //Maybe remove preload handler
  281.   if ((argArray.length-2)%2 == 1) { //if extra arg
  282.     document.preloadId = argArray[argArray.length-1]; //unique id exists, get it
  283.     obj = dreamweaver.getDocumentDOM("document").body;
  284.     if (obj.innerHTML.indexOf(document.preloadId) == -1) // if swap image not just moved
  285.       delHandler(obj,"onLoad","MM_preloadImages",document.preloadId);
  286.   }
  287.  
  288.   //Maybe remove swap restore handler
  289.   selObj=dreamweaver.getBehaviorElement();
  290.   /* selObj appears to always be null, so we never delete the
  291.     GrpRestore.  Oh well... jba */
  292.   if (selObj && selObj.tagName != "A") selObj = selObj.parentNode; //move out to A tag if needed
  293.   alert(selObj);
  294.   if (selObj && selObj.tagName == "A") {
  295.     delHandler(selObj,'onMouseOut','GrpRestore', group);
  296.   }
  297.  
  298. }
  299.  
  300.  
  301.  
  302.  
  303. //***************** LOCAL FUNCTIONS  ******************
  304.  
  305. //Load the select menu with image names.
  306. //Also sets the global property MM_myImgSrcs to the right num of items.
  307.  
  308. function initializeUI(){
  309.   var niceNameSrcArray, nameArray, i, selTag="";
  310.   var imgSrcArray = new Array();
  311.  
  312.   //Determine if RESTORE is an option. If not, remove UI for it
  313.   //the dreamweaver.getBehaviorTag() check ensures the checkbox
  314.   //is not available if a behavior is attached to a timeline
  315.       var removeCheckbox = false;
  316.       if (!dreamweaver.getBehaviorTag() )  //if behavior is in a timeline
  317.         removeCheckbox = true;
  318.       else{
  319.         if (dreamweaver.getBehaviorElement()) selTag = dreamweaver.getBehaviorElement().tagName;
  320.         if (!selTag) selTag = getSelectionTag();
  321.         if (selTag!="A" && selTag!="IMG")  //if sel not A or IMG
  322.           removeCheckbox = true;
  323.       }  
  324.       if (removeCheckbox){
  325.         var theObj = findObject("restoreOption");
  326.         if (theObj) theObj.outerHTML = ""; //remove restoreOption checkbox
  327.       }
  328.   
  329.  
  330.   //Create unique ID in case of preload
  331.   document.preloadId = "#"+((new Date()).getTime());
  332.  
  333.   //Build and load picklist of images
  334.   niceNameSrcArray = getAllObjectRefs("IE 4.0","IMG");
  335.   nameArray = niceNames(niceNameSrcArray,TYPE_Image);
  336.   for (i=0; i<nameArray.length; i++){
  337.     document.theForm.menu.options[i]=new Option(nameArray[i]); //load menu
  338.     imgSrcArray[i] = "";
  339.   }
  340.   pickSelectedImage(); //if an image is selected, selects it in the picklist
  341.   document.MM_myImgSrcs = imgSrcArray; //set global
  342.  
  343.   document.theForm.imgSrc.focus(); //set focus on textbox
  344.   document.theForm.imgSrc.select(); //set insertion point into textbox
  345. }
  346.  
  347.  
  348.  
  349. //Given imageSrc in form, looks up the menu's selection number, and stores the
  350. //new imageSrc at that position in the global document property "MM_myImgSrcs".
  351.  
  352. function storeImgSrc(){
  353.   var newImgSrc, imgSrcArray, menuIndex, newMenuText;
  354.  
  355.   newImgSrc = document.theForm.imgSrc.value;
  356.   imgSrcArray = document.MM_myImgSrcs; //get the prior list of imgSrcs
  357.   menuIndex = document.theForm.menu.selectedIndex; //get index to swap
  358.   imgSrcArray[menuIndex] = newImgSrc;   //swap
  359.   document.MM_myImgSrcs = imgSrcArray;   //rewrite list
  360.   if (newImgSrc) {  //if non-empty, mark with  *
  361.     addStarToMenuItem(document.theForm.menu, menuIndex);
  362.   } else { //nothing to store, strip off any previous star
  363.     newMenuText = stripStar(document.theForm.menu.options[menuIndex].text); //remove if old star
  364.     document.theForm.menu.options[menuIndex]=new Option(newMenuText); //add new line to menu
  365.   }
  366.   document.theForm.menu.selectedIndex = menuIndex; //reset selection index
  367. }
  368.  
  369.  
  370. //Looks at the menu of names, and returns the imgSrc associated with the
  371. //selected item. Example: if the 2nd menu item's selected, returns 2nd item
  372. //stored in property "MM_myImgSrcs".
  373.  
  374. function displayImgSrc(){
  375.   var imgSrcArray, curImageSrcNum, imgSrc;
  376.  
  377.   imgSrcArray = document.MM_myImgSrcs; //get the list of imgSrcs
  378.   curImageSrcNum = document.theForm.menu.selectedIndex; //get index selected
  379.   imgSrc = imgSrcArray[curImageSrcNum];   //lookup imgSrc
  380.   document.theForm.imgSrc.value= imgSrc;    //write into text field
  381. }
  382.  
  383.  
  384.  
  385. //Invokes dialog to allow user to select filename. Puts value in text input.
  386.  
  387. function browseFileAndStore(){
  388.   var fileName;
  389.   fileName = browseForFileURL("select", "", true);  //returns a local filename
  390.   if (fileName) {
  391.     document.theForm.imgSrc.value = fileName;
  392.     storeImgSrc();
  393.   }
  394. }
  395.  
  396.  
  397. function pickSelectedImage(){
  398.   var imgsArray = document.MM_imgObjsArray = createObjsArray("IMG");
  399.   var arrLen = imgsArray.length;
  400.   var selArr = dreamweaver.getSelection();
  401.   var selObj = dreamweaver.offsetsToNode(selArr[0],selArr[1]);
  402.   
  403.   for (i=0;i<arrLen;i++){
  404.     if (imgsArray[i]==selObj)
  405.       document.theForm.menu.selectedIndex=i;  
  406.   }
  407. }
  408.  
  409. function identifyBehaviorArguments(fnCallStr) {
  410.   var argList, argArray, numArgGroups, i;
  411.  
  412.   argList = "ign"; /* ignore the group name */
  413.   argArray = extractArgs(fnCallStr);
  414.   numArgGroups = (argArray.length - 2) / 2; //args come in pairs
  415.   for (i=0; i<numArgGroups; i++) {          //with each NSobj,IEobj,URL triplet
  416.     argList += ((argList)?",":"")+"ignore,DEP";
  417.   }
  418.   return argList;
  419. }
  420.  
  421. //Creates a unique name for objs of tagName, using tagString
  422. //for instance: if tagString = Image, returns a name like Image1
  423. function getUniqueName(tagName,tagString,tagNameObjsArray){ 
  424.   var frameListSize,objName,dupe=true,counter=1;
  425.   var objsArray=arguments[2],objsArrayLen = objsArray.length;
  426.   
  427.     while (dupe==true){ //check new name against name of all other tagName objs
  428.         dupe=false;
  429.         objName = tagString + counter++; 
  430.         //iterates through possible names: tagName1, then tagName2, etc.
  431.         for (i=0;dupe==false && i<objsArrayLen;i++){
  432.           //if another object of this type has the same name
  433.           if (objsArray[i].getAttribute("name") == objName) 
  434.             dupe=true; //then repeat the loop, trying a new name
  435.         }
  436.     }
  437.     return objName; //return new name 
  438.     
  439. }
  440.  
  441. //Returns an array of objects of tagName
  442. //If doc is in a frameset, searches all frames in parent
  443. function createObjsArray(tagName){
  444.   var frameListLen,objsArray=new Array(),thisFrame;
  445.   if (dreamweaver.getDocumentDOM('parent')){//if frames
  446.     frameListLen = dreamweaver.getDocumentDOM('parent').getElementsByTagName('frame').length;
  447.     for (i=0;i<frameListLen;i++){
  448.       thisFrame = 'parent.frames[' + i + ']';
  449.       objsArray = objsArray.concat(dreamweaver.getDocumentDOM(thisFrame).getElementsByTagName(tagName));
  450.     }
  451.   } else //if no frames
  452.     objsArray = dreamweaver.getDocumentDOM("document").getElementsByTagName(tagName);
  453.   return objsArray;     
  454. }
  455.  
  456. //*************** GENERIC DOM MANIPULATION FNS *****************
  457.  
  458. //Returns a function call if exists in event handler.
  459. //  obj       - DOM object, such as dreamweaver.getDocumentDOM().body
  460. //  eventName - "onLoad", "onClick" etc (not case sensitive)
  461. //  fnName    - "MM_preloadImages" etc.
  462. //  optStr    - (optional) function call must contain this string to be found
  463. //Given <TAG onEvent="aaa();bbb();ccc()">,
  464. //calling getHandler(tagObj,'onEvent','bbb') will
  465. //return "bbb()". Returns empty if event or fn don't exist.
  466.  
  467. function getHandler(obj,eventName,fnName, optStr) {
  468.   var eventStr,fnArray,i,theChunk,retVal = "";
  469.   eventStr = obj.getAttribute(eventName);
  470.   if (eventStr) { //find previous call, or add it
  471.     fnArray = dreamweaver.getTokens(eventStr,";");
  472.     for (i=0; i<fnArray.length; i++) { //look at each code chunk
  473.       if (fnArray[i].indexOf(fnName+'(') != -1 && (!optStr ||  //fn call found
  474.           fnArray[i].indexOf(optStr) != -1)) {
  475.         retVal = fnArray[i]; break;
  476.     } }
  477.   }
  478.   return retVal
  479. }
  480.  
  481.  
  482.  
  483. //Replaces or adds a fn call to an event handler
  484. //  obj       - DOM object, such as dreamweaver.getDocumentDOM().body
  485. //  eventName - "onLoad", "onClick" etc (not case sensitive)
  486. //  fnCall    - "myFun('arg1','arg2')" etc.
  487. //  optStr    - (optional) function call must contain this string to be found
  488. //Given <TAG onEvent="aaa();bbb();ccc()">,
  489. //calling setHandler(tagObj,'onEvent','bbb(1,2)') will
  490. //replace "bbb()" with the altered fn call. If the event
  491. //does not exist, adds it. It fn didn't exist, adds it to the
  492. //end of the list.
  493.  
  494. function setHandler(obj,eventName,fnCall, optStr) {
  495.   var eventStr,fnName,fnArray=new Array(),i=0;
  496.   eventStr = obj.getAttribute(eventName);
  497.   if (eventStr) { //if event exists
  498.     fnName = fnCall.substring(0,fnCall.indexOf("("));
  499.     fnArray = dreamweaver.getTokens(eventStr,";");
  500.     for (i; i<fnArray.length; i++) //search for fnName
  501.       if (fnArray[i].indexOf(fnName+'(') != -1 && (!optStr ||  //fn call found
  502.           fnArray[i].indexOf(optStr) != -1)) break;
  503.   }
  504.   fnArray[i] = fnCall;
  505.   obj.setAttribute(eventName,fnArray.join(";"));
  506.   return true
  507. }
  508.  
  509.  
  510.  
  511. //Deletes a fn call from an event handler
  512. //  obj       - DOM object, such as dreamweaver.getDocumentDOM().body
  513. //  eventName - "onLoad", "onClick" etc (not case sensitive)
  514. //  fnName    - "MM_preloadImages" etc.
  515. //  optStr    - (optional) function call must contain this string to be found
  516. //Given <TAG onEvent="aaa();bbb();ccc()">,
  517. //calling delHandler(tagObj,'onEvent','bbb') will
  518. //remove "bbb();". If it is the last fn in the handler,
  519. //removes the event entirely.
  520.  
  521. function delHandler(obj,eventName,fnName, optStr) {
  522.   var eventStr,fnArray=new Array(),i=0,j;
  523.   eventStr = obj.getAttribute(eventName);
  524.   if (eventStr) { //if event exists
  525.     fnArray = dreamweaver.getTokens(eventStr,";");
  526.     for (i; i<fnArray.length; i++) { //look at each code chunk
  527.       if (fnArray[i].indexOf(fnName+'(') != -1 && (!optStr ||  //fn call found
  528.           fnArray[i].indexOf(optStr) != -1)) { //and, if given, optStr exists
  529.         if (fnArray.length == 1) { //if last one, remove attribute
  530.           obj.removeAttribute(eventName);
  531.         } else { //pull out
  532.           for (j=i; j<fnArray.length; j++) fnArray[j] = fnArray[j+1]; //shift array
  533.           fnArray.length--;
  534.           obj.setAttribute(eventName,fnArray.join(';'));
  535.         }
  536.         break;
  537.     } }
  538.   }
  539.   return true
  540. }
  541.  
  542.  
  543.  
  544. //Returns the tag for the current selection, such as
  545. //IMG, A, DIV etc. Always uppercase.
  546.  
  547. function getSelectionTag() {
  548.   var retVal = "";
  549.   var selArr = dreamweaver.getSelection()
  550.   var selObj=dreamweaver.offsetsToNode(selArr[0],selArr[1]);
  551.     if (selObj && selObj.tagName) retVal = selObj.tagName;
  552.   return retVal
  553. }
  554.  
  555. //**************** GENERIC FUNCTIONS ****************
  556.  
  557. //function extractArgs(behFnCallStr){
  558. //function stripStar(theStr) {
  559. //function addStarToMenuItem(theSelect,menuIndex) {
  560. //function escQuotes(theStr){
  561. //function unescQuotes(theStr){
  562. //function niceNames(objRefArray,objTypeStr) {
  563. //function nameReduce (objName) {
  564. //function errMsg() {
  565. //function findObject(objName,  parentObj) {
  566.  
  567.  
  568.  
  569. //**************** GENERIC FUNCTIONS ****************
  570.  
  571. //function extractArgs(behFnCallStr){
  572. //function stripStar(theStr) {
  573. //function addStarToMenuItem(theSelect,menuIndex) {
  574. //function escQuotes(theStr){
  575. //function unescQuotes(theStr){
  576. //function niceNames(objRefArray,objTypeStr) {
  577. //function nameReduce (objName) {
  578. //function errMsg() {
  579. //function findObject(objName,  parentObj) {
  580.